<?php include("template_top.php"); ?>
<div id="container2" class="highcharts-container" style="height:410px; margin: 0 2em; clear:both; min-width: 600px">
</div>
<?php
$sql = "SELECT * FROM `tbRegistrationLog` WHERE `sDate` = :date AND `sLocation` = 'S112'";
$q = db::Query($sql, array(':date'=>date("M j, Y")));
$hours = array();
while($row = $q->fetch()){
	$row['sTime'] = date("G:i", strtotime($row['sTime']));
	$temp = explode(":", $row['sTime']);
	if($hours[$temp[0]] == NULL){
		$hours[$temp[0]] = 1;
	}else{
		$hours[$temp[0]] ++;
	}
}
$c = 6;
while($c != 20){
	if($hours[$c] == NULL){
		$hours[$c] = 0;
	}
	$c ++;
}

$sql = "SELECT * FROM `tbRegistrationLog` WHERE `sDate` = :date AND `sLocation` = 'S201'";
$q = db::Query($sql, array(':date'=>date("M j, Y")));
$hours201 = array();
while($row = $q->fetch()){
	$row['sTime'] = date("G:i", strtotime($row['sTime']));
	$temp = explode(":", $row['sTime']);
	if($hours201[$temp[0]] == NULL){
		$hours201[$temp[0]] = 1;
	}else{
		$hours201[$temp[0]] ++;
	}
}
$c = 6;
while($c != 20){
	if($hours201[$c] == NULL){
		$hours201[$c] = 0;
	}
	$c ++;
}
?>
<script>
var chart;
$(document).ready(function() {
   chart = new Highcharts.Chart({
      chart: {
         renderTo: 'container2', 
         defaultSeriesType: 'area'
      },
      title: {
         text: 'Registration Computer Activity'
      },
	  subtitle: {
		  text: '<?php echo date("F j, Y") ?>'
	  },
      xAxis: {
         labels: {
            formatter: function() {
				if(this.value > 12){
					var temp = this.value - 12;
					temp = temp + " PM";
				}else if(this.value == 12){
					var temp = this.value;
					temp = temp + " PM";
				}else{
					var temp = this.value;
					temp = temp + " AM";
				}
                return temp; // clean, unformatted number for year
            }
         },
		 tickInterval: 1
      },
      yAxis: {
         title: {
            text: ''
         },
         labels: {
            formatter: function() {
               return this.value+' Visits';
            }
         }
      },
      tooltip: {
         formatter: function() {
            return Highcharts.numberFormat(this.y, 0) +' Visitors </b>';
         }
      },
      plotOptions: {
         area: {
            pointStart: 6,
            marker: {
               enabled: false,
               symbol: 'circle',
               radius: 2,
               states: {
                  hover: {
                     enabled: true
                  }
               }
            }
         }
      },
      series: [{
         name: 'S-112',
         data: [<?php echo $hours[6] ?>, <?php echo $hours[7] ?>, <?php echo $hours[8] ?>, <?php echo $hours[9] ?>, <?php echo $hours[10] ?>, <?php echo $hours[11] ?>, <?php echo $hours[12] ?>, <?php echo $hours[13] ?>, <?php echo $hours[14] ?>, <?php echo $hours[15] ?>, <?php echo $hours[16] ?>, <?php echo $hours[17] ?>, <?php echo $hours[18] ?>, <?php echo $hours[19] ?>]
      },
	  {
         name: 'S-201',
         data: [<?php echo $hours201[6] ?>, <?php echo $hours201[7] ?>, <?php echo $hours201[8] ?>, <?php echo $hours201[9] ?>, <?php echo $hours201[10] ?>, <?php echo $hours201[11] ?>, <?php echo $hours201[12] ?>, <?php echo $hours201[13] ?>, <?php echo $hours201[14] ?>, <?php echo $hours201[15] ?>, <?php echo $hours201[16] ?>, <?php echo $hours201[17] ?>, <?php echo $hours201[18] ?>, <?php echo $hours201[19] ?>]
      }]
   });
   
   
});
</script>

<div id="container" class="highcharts-container" style="height:410px; margin: 0 2em; clear:both; min-width: 600px">
</div>
<?php
$sql = "SELECT * FROM `tbRegistrationLog` WHERE `sDate` LIKE :date AND `sLocation` = 'S112'";
$q = db::Query($sql, array(':date'=>date("M")."%"));
$hours = array();
while($row = $q->fetch()){
	$temp = explode(" ", $row['sDate']);
	$temp = explode(",", $temp[1]);
	$temp = $temp[0];
	if($hours[$temp] == NULL){
		$hours[$temp] = 1;
	}else{
		$hours[$temp] ++;
	}
}

$c = 1;
while($c <= date("j")){
	if($hours[$c] == NULL){
		$hours[$c] = 0;
	}
	$c ++;
}
ksort($hours);

$sql = "SELECT * FROM `tbRegistrationLog` WHERE `sDate` LIKE :date AND `sLocation` = 'S201'";
$q = db::Query($sql, array(':date'=>date("M")."%"));
$hours201 = array();
while($row = $q->fetch()){
	$temp = explode(" ", $row['sDate']);
	$temp = explode(",", $temp[1]);
	$temp = $temp[0];
	if($hours201[$temp] == NULL){
		$hours201[$temp] = 1;
	}else{
		$hours201[$temp] ++;
	}
}

$c = 1;
while($c <= date("j")){
	if($hours201[$c] == NULL){
		$hours201[$c] = 0;
	}
	$c ++;
}
ksort($hours201);
?>
<script>
var chart;
$(document).ready(function() {
   chart = new Highcharts.Chart({
      chart: {
         renderTo: 'container', 
         defaultSeriesType: 'column'
      },
      title: {
         text: 'Registration Computer Activity'
      },
	  subtitle: {
		  text: '<?php echo date("F Y") ?>'
	  },
      xAxis: {
         labels: {
            formatter: function() {
                return "<?php echo date("n") ?>/"+this.value+"/<?php echo date("Y") ?>"; // clean, unformatted number for year
            }
         },
		 tickInterval: 1
      },
      yAxis: {
         title: {
            text: ''
         },
         labels: {
            formatter: function() {
               return this.value+' Visits';
            }
         }
      },
      tooltip: {
         formatter: function() {
            return Highcharts.numberFormat(this.y, 0) +' Visitors </b>';
         }
      },
      plotOptions: {
         area: {
            pointStart: 1,
            marker: {
               enabled: false,
               symbol: 'circle',
               radius: 2,
               states: {
                  hover: {
                     enabled: true
                  }
               }
            }
         }
      },
      series: [{
         name: 'S-112',
         data: [<?php $first = true;foreach($hours as $value){if(!$first){echo ", ";};$first = false;echo $value;} ?>]
      },
	  {
         name: 'S-201',
         data: [<?php $first = true;foreach($hours201 as $value){if(!$first){echo ", ";};$first = false;echo $value;} ?>]
      }]
   });
   
   
});
</script>
<?php include("template_bot.php"); ?>